package kr.haggenna.reservation.dao;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Component;

import kr.haggenna.item.domain.Purchase;
import kr.haggenna.reservation.domain.ReservationCommand;

@Component
public class ReservationDaoImpl extends SqlSessionDaoSupport implements ReservationDao{

	@Override
	public void insertReservation(ReservationCommand reservation) {
		getSqlSession().insert("insertReservation", reservation);
	}

	@Override
	public ReservationCommand getCurrentReservationByEmail(String email) {
		ReservationCommand reservation = getSqlSession().selectOne("getCurrentReservationByEmail", email);
		return reservation;
	}

	@Override
	public List<ReservationCommand> getReservationList() {
		List<ReservationCommand> reservationList = getSqlSession().selectList("getReservationList");
		return reservationList;
	}
	
	@Override
	public List<ReservationCommand> getReservationListByEmail(String email) {
		List<ReservationCommand> reservationList = getSqlSession().selectList("getReservationListByEmail", email);
		return reservationList;
	}
	
	@Override
	public int getRowCount() {
		int count = getSqlSession().selectOne("getReservationCount");
		return count;
	}
	
	@Override
	public List<ReservationCommand> list(Map<String, Object> map) {
		List<ReservationCommand> list = getSqlSession().selectList("getReservationListPage",map);
		return list;
	}
}
